package com.xn.app.muying.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.xn.app.muying.R;
import com.xn.app.muying.sqlite.DBManager;
import com.xn.app.muying.util.BaseActivity;

public class ZhangHuActivity extends BaseActivity {
    Button xiu_gai_mima;
    private TextView tui_chu;
    //数据库
    private DBManager db = null;
    //类对象
    public static ZhangHuActivity zhangHuActivity = null;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_zhang_hu);
        //获得数据库对象
        db = new DBManager(this);
        zhangHuActivity = this;
        //返回键
        findViewById(R.id.guan_bi).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        //修改密码
        xiu_gai_mima = (Button) findViewById(R.id.xiu_gai_mima);
        xiu_gai_mima.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(ZhangHuActivity.this, YanZhengActivity.class);
                intent.putExtra("tag", "1");
                startActivity(intent);
            }
        });
        //会员服务
        findViewById(R.id.vip_service).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(ZhangHuActivity.this, VIPActivity.class);
                startActivity(intent);
            }
        });
        //退出键
        tui_chu = (TextView) findViewById(R.id.tui_chu);
        tui_chu.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (db.selectNull(DBManager.USER_TABLE) != 0) {
                    db.delete(DBManager.USER_TABLE);
                }
                if (db.selectNull(DBManager.CACHE_TABLE) != 0) {
                    db.delete(DBManager.CACHE_TABLE);
                }
                sendBroadcast(new Intent("bei_er").putExtra("bei_er", 1));
                finish();
            }
        });
    }

    @Override
    protected void onResume() {
        super.onResume();
    }
}